<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title language="html:editMenuPage"></title>
    <link rel="stylesheet" type="text/css" href="/static/common/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/static/common/easyui/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="/static/common/easyui/themes/IconExtension.css">
    <link rel="stylesheet" href="/static/common/pnotify/pnotify.custom.min.css" media="all" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/admin.css">
    <link rel="stylesheet" href="/static/common/animate/animate.min.css">
</head>
<body>
    <form action="/intendant/site/editMenuSubmit">
        <input class="easyui-validatebox" type="hidden" name="id" value="{{.menu.Id}}" data-options="required:true,validType:['numericNoHeadZero','length[1,8]']">
        <div class="frame_form_table">
            <table cellpadding="0" cellspacing="0" class="table_form" width="100%">
                <tbody>
                    <tr>
                        <td width="40" language="table:superiorMenu"></td>
                        <td width="160"><input id="menuselect" class="length_3" name="pid" value="{{.menu.Pid}}"></td>
                    </tr>
                    <tr>
                        <td width="40" language="table:menuChinese"></td>
                        <td width="190"><input class="easyui-validatebox length_5" value="{{.menu.Name}}" type="text" name="name" data-options="required:true,validType:['chinese','length[2,50]']"></td>
                    </tr>
                    <tr>
                        <td width="40" language="table:menuEnglish"></td>
                        <td width="190"><input class="easyui-validatebox length_5" value="{{.menu.En}}" type="text" name="en" data-options="required:true,validType:['englishSpace','length[2,50]']"></td>
                    </tr>
                    <tr>
                        <td width="40" language="table:menuUrl"></td>
                        <td width="190"><input class="easyui-validatebox length_5" value="{{.menu.Url}}" type="text" name="url" data-options="required:true,validType:['menuUrl','length[2,50]']"></td>
                    </tr>
                    <tr>
                        <td width="40" language="table:menuSort"></td>
                        <td width="190"><input class="easyui-validatebox length_5" value="{{.menu.Sort}}" type="text" name="sort" data-options="required:true,validType:['numeric','length[1,3]']"></td>
                    </tr>
                    <tr>
                        <td width="40" language="table:menuIcon"></td>
                        <td>
                            <input id="hm_menu_icons_input" name="icon" type="hidden" value="{{.menu.Icon}}">
                            <strong id="hm_menu_icons"><i class='{{.menu.Icon}}'></i></strong>
                            <a href="#" class="easyui-linkbutton" plain="true" onclick="parent.hm.showMenuIcons(hm.language.selectIcons)" language="html:selectIcons"></a>
                        </td>
                    </tr>
                    <tr>
                        <td width="40" language="table:isshow"></td>
                        <td width="190"><input id="isshow"></td>
                        <input type="hidden" name="isshow" value="{{.menu.Isshow}}">
                    </tr>
                </tbody>
            </table>
        </div>
        <div id="hm_toolbar">
            <a onclick="javascript:history.back(-1);" class="easyui-linkbutton" iconCls="icon-arrow_turn_left" plain="true" language="html:goback"></a>
            <a id="btn" href="" class="easyui-linkbutton" iconCls="icon-arrow_refresh" plain="true" language="html:refreshCurrent"></a>
            <a id="btn" href="javascript:void(0)" onclick="hm.ajaxAddEdit(editUserFunc,this)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" language="html:ajaxEdit"></a>
        </div>
    </form>
</body>
<script type="text/javascript" src="/static/common/easyui/jquery.min.js"></script>
<script type="text/javascript" src="/static/common/easyui/jquery.cookie.js"></script>
<script type="text/javascript" src="/static/common/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/common/pnotify/pnotify.custom.min.js"></script>
<script type="text/javascript" src="/static/admin/js/language.js"></script>
<script type="text/javascript" src="/static/admin/js/global.js"></script>
<script type="text/javascript">
var data = [];
var menudata = $.parseJSON({{.json}});
var topdata = '{"id":0,"url":"topMenu","text":"顶级菜单","pid":0,"isshow":1,"en":"Top menu","iconCls":"icon-eject_green"}';
data.push(JSON.parse(topdata));
$.each(menudata, function(index, obj) {
    data.push(obj);
});
var lang = hm.getLanguage('easyui-tree');
$('#menuselect').combotree({
    required: true,
    textField: lang,
    data: data,
    formatter:function(node){
		return node[lang];
	}
});
var st = hm.switchStatus({{.menu.Isshow}});
$('#isshow').switchbutton({
    checked: st,
    onText: hm.language.on,
    offText: hm.language.off,
    onChange: function(checked) {
        if(checked == true){
            $('input[name=isshow]').val(1);
        }else{
            $('input[name=isshow]').val(0);
        }
    }
});
function editUserFunc(data){
    var failed = hm.language.editFailed ? hm.language.editFailed : "Edit failed!",
        success = hm.language.editSuccess ? hm.language.editSuccess : "Edit successed!",
        unknownError = hm.language.unknownError ? hm.language.unknownError : "Unknow error!",
        noAuth = hm.language.noAuth ? hm.language.noAuth : "You have no authority",
        menuCheckName = hm.language.menuCheckName ? hm.language.menuCheckName : "Chinese name already exists!",
        menuCheckUrl = hm.language.menuCheckUrl ? hm.language.menuCheckUrl : "Menu URL already exists!",
        menuCheckEn = hm.language.menuCheckEn ? hm.language.menuCheckEn : "English name already exists!",
        menuTestPid = hm.language.menuTestPid ? hm.language.menuTestPid : "The upper menu ID input is illegal!",
        menuTestName = hm.language.menuTestName ? hm.language.menuTestName : "Chinese name must be Chinese!",
        menuTestSort = hm.language.menuTestSort ? hm.language.menuTestSort : "Menu ordering is illegal!",
        menuTestIcon = hm.language.menuTestIcon ? hm.language.menuTestIcon : "Menu icon entry is illegal!",
        menuTestIsshow = hm.language.menuTestIsshow ? hm.language.menuTestIsshow : "Menu isshow input is illegal!",
        menuTestUrl = hm.language.menuTestUrl ? hm.language.menuTestUrl : "Menu url entry is illegal!",
        menuTestEn = hm.language.menuTestEn ? hm.language.menuTestEn : "English name only allows English and spaces!";
    if (data.status == 21) {
        parent.hm.notice("error", menuCheckName + data.info);
    } else if(data.status == 22){
        parent.hm.notice("error", menuCheckUrl + data.info);
    } else if(data.status == 23){
        parent.hm.notice("error", menuCheckEn + data.info);
    } else if (data.status == 66) {
        parent.hm.notice("error", noAuth);
    } else if(data.status == 11){
        parent.hm.notice("error", menuTestPid + data.info);
    } else if(data.status == 12){
        parent.hm.notice("error", menuTestName + data.info);
    } else if(data.status == 13){
        parent.hm.notice("error", menuTestSort + data.info);
    } else if(data.status == 14){
        parent.hm.notice("error", menuTestIcon + data.info);
    } else if(data.status == 15){
        parent.hm.notice("error", menuTestIsshow + data.info);
    } else if(data.status == 16){
        parent.hm.notice("error", menuTestUrl + data.info);
    } else if(data.status == 17){
        parent.hm.notice("error", menuTestEn + data.info);
    } else if(data.status == 18){
        parent.hm.notice("error", menuTestPid + data.info);
    } else if(data.status == 4){
        parent.hm.notice("error", failed + data.info);
    } else if(data.status == 1){
        parent.hm.notice("success", success + data.info);
        parent.hm.refreshTab();
    }else{
        parent.hm.notice("error",unknownError+ data.info);
    }
}
</script>
</html>
